!-----------------------------------------------------------------------
!  Copyright (c) 2020 Feasa Enterprises Ltd.
!  Rev 3.0  August 2020
!
!  All Rights Reserved.  Reproduction, adaptation, or translation
!  without prior written permission is prohibited, except as allowed
!  under the copyright laws.
!
!-----------------------------------------------------------------------
!
! Device        : Feasa_20i
! Manufacturer  : Feasa Enterprises Ltd.
! Description   : 20 Channel device to interrogate a LED
! Package       : 20 pin
! Test Platform : 3070
! Safeguard     : cmos_3v3
! Test          : Set / Reset setfactor in Frequency mode
!-----------------------------------------------------------------------------
! WARNING:  This is a Led Analyser function referenced by a PDL.
!
!   This test is not intended to be used directly for a Led analyser.
!   Instead, a part description library for the Led analyser should be
!   used where the part description language of that file refers to
!   this file as the part number of one of it's several "sub-components" .
!   Notice also that this test uses signal names rather than ordinal
!   pin numbers.  The referencing part description library should map
!   the device's actual pin numbers to these signal names.
!
!
! Additional Comments:
!
!   This test captures the raw data of the LED under test in Frequency mode.
!
!-------------------------------------------------------------------------------
!
! The following Unit has to be executed before any of the
! Following commands can be run
!
! Reset/Initializer Led Analyser  Address 11111  31 dec
!
! The following commands are possible using this test
! All that has to be done is uncomment the desired command and
! Comment out all others
!
! Decrement exposure factor       Address 11100  28 dec
! Reset exposure factor           Address 11101  29 dec
! Increment exposure factor       Address 11110  30 dec
!
!*************************************************************
! All commands are executed on the falling edge of WE_bar
! In order for a capture to be executed the capture command
! has to be preceeded by a Reset (Initialize) command
!
! The sequence for making an Auto Range Capture is as follows:
! - Set OE_bar to [0} to enable the outputs
! - Set Reset to [1] to prevent the board from doing a soft reset
! - Set WE_bar to [1]
! - Set Address to [11111] (Reset/Initialize) command (Substitute command here
! - Set WE_bar to [0]      (execute the command)
! - The RyBy_bar (output goes high and then low to indicate
!                 that the command has been successful)
! - Set WE_bar to [1]
! - Set the address to [00000] (make a capture)
! - Set WE_bar to [0]      (execute the command)
! - The RyBy_bar (output goes high and then low to indicate
!                 that the command has been successful)
!                 The length of time that the RyBy_bar signal
!                 is high is determined by the type of capture
!                 and also on the sensitivity factor being used
!
!*********************************************************************

sequential
test time 8

vector cycle 112u
receive delay 111u

set terminators to on

assign Ser_out            to pins "Ser_out"
assign Ser_in             to pins "Ser_in"

assign Ser_clk            to pins "Ser_clk"

assign GND1               to pins "GND1"

assign Reset              to pins "Reset"

assign OE_bar             to pins "OE_bar"
assign Ext_trig           to pins "Ext_trig"

assign PWM                to pins "PWM"

assign Addr_0             to pins "Addr_0"
assign Addr_1             to pins "Addr_1"
assign Addr_2             to pins "Addr_2"
assign Addr_3             to pins "Addr_3"
assign Addr_4             to pins "Addr_4"

assign WE_bar             to pins "WE_bar"
assign Int                to pins "Int"
assign Color              to pins "Color"
assign Sat                to pins "Sat"

assign RyBy_bar           to pins "RyBy_bar"

assign VCC                to pins "VCC"
assign GND                to pins "GND"

power  VCC, GND, GND1

family   CMOS_3V3

inputs   OE_bar, Ext_trig, PWM, Addr_0, Addr_1, Addr_2, Addr_3,Addr_4, WE_bar, Reset

outputs  RyBy_bar

nondigital Int, Color, Sat, Ser_in, Ser_clk, Ser_out


!********************************************************************
vector Initialize
     set Reset  to "1"
     set WE_bar to "1"
     set OE_bar to "0"
     set Addr_0 to "1"
     set Addr_1 to "1"
     set Addr_2 to "1"
     set Addr_3 to "1"
     set Addr_4 to "1"
end vector

vector Keep
     set Reset  to "1"
     set WE_bar to "k"
     set OE_bar to "k"
     set Addr_0 to "k"
     set Addr_1 to "k"
     set Addr_2 to "k"
     set Addr_3 to "k"
     set Addr_4 to "k"
end vector

vector Reset_lo
     initialize to Keep
     set Reset   to "0"
end vector

vector Reset_hi
     initialize to Keep
     set Reset   to "1"
end vector

vector RyBy_bar_lo
     initialize to Keep
     set RyBy_bar   to "0"
end vector

vector RyBy_bar_hi
     initialize to Keep
     set RyBy_bar   to "1"
end vector

vector WE_bar_lo
     initialize to Keep
     set WE_bar   to "0"
end vector

vector WE_bar_hi
     initialize to Keep
     set WE_bar   to "1"
end vector

vector OE_bar_lo
     initialize to Keep
     set OE_bar   to "0"
end vector

vector OE_bar_hi
     initialize to Keep
     set OE_bar   to "1"
end vector

vector Addr_00
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "0"
     set Addr_2 to "0"
     set Addr_3 to "0"
     set Addr_4 to "0"
end vector

vector Addr_01
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "0"
     set Addr_2 to "0"
     set Addr_3 to "0"
     set Addr_4 to "0"
end vector

vector Addr_02
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "1"
     set Addr_2 to "0"
     set Addr_3 to "0"
     set Addr_4 to "0"
end vector

vector Addr_03
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "1"
     set Addr_2 to "0"
     set Addr_3 to "0"
     set Addr_4 to "0"
end vector

vector Addr_04
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "0"
     set Addr_2 to "1"
     set Addr_3 to "0"
     set Addr_4 to "0"
end vector

vector Addr_05
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "0"
     set Addr_2 to "1"
     set Addr_3 to "0"
     set Addr_4 to "0"
end vector

vector Addr_06
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "1"
     set Addr_2 to "1"
     set Addr_3 to "0"
     set Addr_4 to "0"
end vector

vector Addr_07
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "1"
     set Addr_2 to "1"
     set Addr_3 to "0"
     set Addr_4 to "0"
end vector

vector Addr_08
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "0"
     set Addr_2 to "0"
     set Addr_3 to "1"
     set Addr_4 to "0"
end vector

vector Addr_09
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "0"
     set Addr_2 to "0"
     set Addr_3 to "1"
     set Addr_4 to "0"
end vector

vector Addr_10
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "1"
     set Addr_2 to "0"
     set Addr_3 to "1"
     set Addr_4 to "0"
end vector

vector Addr_11
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "1"
     set Addr_2 to "0"
     set Addr_3 to "1"
     set Addr_4 to "0"
end vector

vector Addr_12
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "0"
     set Addr_2 to "1"
     set Addr_3 to "1"
     set Addr_4 to "0"
end vector

vector Addr_13
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "0"
     set Addr_2 to "1"
     set Addr_3 to "1"
     set Addr_4 to "0"
end vector

vector Addr_14
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "1"
     set Addr_2 to "1"
     set Addr_3 to "1"
     set Addr_4 to "0"
end vector

vector Addr_15
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "1"
     set Addr_2 to "1"
     set Addr_3 to "1"
     set Addr_4 to "0"
end vector

vector Addr_16
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "0"
     set Addr_2 to "0"
     set Addr_3 to "0"
     set Addr_4 to "1"
end vector

vector Addr_17
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "0"
     set Addr_2 to "0"
     set Addr_3 to "0"
     set Addr_4 to "1"
end vector

vector Addr_18
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "1"
     set Addr_2 to "0"
     set Addr_3 to "0"
     set Addr_4 to "1"
end vector

vector Addr_19
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "1"
     set Addr_2 to "0"
     set Addr_3 to "0"
     set Addr_4 to "1"
end vector

vector Addr_20
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "0"
     set Addr_2 to "1"
     set Addr_3 to "0"
     set Addr_4 to "1"
end vector

vector Capture_range1
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "0"
     set Addr_2 to "1"
     set Addr_3 to "0"
     set Addr_4 to "1"
end vector

vector Capture_range2
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "1"
     set Addr_2 to "1"
     set Addr_3 to "0"
     set Addr_4 to "1"
end vector

vector Capture_range3
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "1"
     set Addr_2 to "1"
     set Addr_3 to "0"
     set Addr_4 to "1"
end vector

vector Capture_range4
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "0"
     set Addr_2 to "0"
     set Addr_3 to "1"
     set Addr_4 to "1"
end vector


vector Capture_range5
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "0"
     set Addr_2 to "0"
     set Addr_3 to "1"
     set Addr_4 to "1"
end vector

vector Pwm_low
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "1"
     set Addr_2 to "0"
     set Addr_3 to "1"
     set Addr_4 to "1"
end vector

vector Pwm_high
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "1"
     set Addr_2 to "0"
     set Addr_3 to "1"
     set Addr_4 to "1"
end vector

vector Set_factor_down
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "0"
     set Addr_2 to "1"
     set Addr_3 to "1"
     set Addr_4 to "1"
end vector

vector Set_factor_reset
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "0"
     set Addr_2 to "1"
     set Addr_3 to "1"
     set Addr_4 to "1"
end vector

vector Set_factor_up
     initialize to Keep
     set Addr_0 to "0"
     set Addr_1 to "1"
     set Addr_2 to "1"
     set Addr_3 to "1"
     set Addr_4 to "1"
end vector

vector Addr_31
     initialize to Keep
     set Addr_0 to "1"
     set Addr_1 to "1"
     set Addr_2 to "1"
     set Addr_3 to "1"
     set Addr_4 to "1"
end vector

!************  UNITS Section  ****************
! Do not comment out this unit
! Note: this sequence has to be done in the correct order
! The Initialize unit has to be executed before the commands will work
! otherwise the Led Analyser will not capture
! WE_bar going low triggers an event depending on the address
!

unit "Initialize"
     execute Initialize
     execute Addr_31    !Reset the board in preparation for capture
     execute WE_bar_lo  !execute the command

     homingloop
       execute    RyBy_bar_hi exit if pass !check that it goes high
     end homingloop

     homingloop
       execute    RyBy_bar_lo exit if pass !check that it goes low
     end homingloop

     execute WE_bar_hi
end unit



!******************************************************************************!
!*** The Following 3 UNITS are used to set the SET FACTOR of the Analyser  ****!
!*** The Analyser is supplied with the set factor set to 01. It has        ****!
!*** a range of 01 - 15. For very dim LED's the factor can as high as 15.  ****!
!*** When set at factor 15 the Capture time will increase significantly.   ****!
!*** Uncomment the following unit 'set factor Up'                          ****!
!*** and run ONCE to increase the factor by 1. Run the unit twice to       ****!
!*** increase it by 2 etc. Uncomment the 'set Factor Down' unit to         ****!
!*** decrease the factor number. Run this unit twice to decrease it        ****!
!*** by 2 etc. When you are satisfied that the Analyser is set to the      ****!
!*** correct factor for your board COMMENT OUT ALL these units.            ****!
!*** The unit 'set factor reset' will restore factor setting of 01         ****!
!******************************************************************************!

!unit "Set Factor Down"
!     execute Set_factor_down !Set Sensitivity Factor Down
!     execute WE_bar_lo       !execute the command
!
!     homingloop
!       execute    RyBy_bar_hi exit if pass !Check that RyBy_bar goes high
!     end homingloop
!
!     homingloop
!       execute    RyBy_bar_lo exit if pass !Check that RyBy_bar goes low
!     end homingloop
!
!     execute WE_bar_hi
!end unit


!unit "Set Factor Up"
!     execute Set_factor_up   !Set Sensitivity actor Up
!     execute WE_bar_lo       !execute the command
!
!     homingloop
!       execute    RyBy_bar_hi exit if pass !Check that RyBy_bar goes high
!     end homingloop
!
!     homingloop
!       execute    RyBy_bar_lo exit if pass !Check that RyBy_bar goes low
!     end homingloop
!
!     execute WE_bar_hi
!end unit

unit "Set Factor Reset"
     execute Set_factor_reset !Reset the Sensitivity Factor to default [1]
     execute WE_bar_lo        !execute the command

     homingloop
       execute    RyBy_bar_hi exit if pass !Check that RyBy_bar goes high
     end homingloop

     homingloop
       execute    RyBy_bar_lo exit if pass !Check that RyBy_bar goes low
     end homingloop

     execute WE_bar_hi
end unit

!    End of Test



